package com.spring.quickstart.entity;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.NotBlank;
import org.springframework.validation.annotation.Validated;

import com.spring.quickstart.common.validator.groups.Add;
import com.spring.quickstart.common.validator.groups.Mod;

@Validated
public class User {

	@NotBlank(message = "用户编号不能为空", groups = { Mod.class })
	private String userId;

	@NotNull(message = "用户姓名不能为空", groups = { Add.class, Mod.class })
	@Pattern(regexp = "[a-zA-Z0-9_]{5,10}", message = "用户姓名输入不合法")
	private String userName;

	@NotNull(message = "用户密码不能为空", groups = { Add.class })
	@Size(min = 5, max = 10, message = "密码输入不合法", groups = { Add.class, Mod.class })
	private String password;

	private String sex;

	private String email;

	@Pattern(regexp = "^1(3|4|5|7|8)\\d{9}$", message = "手机号码格式错误")
	@NotBlank(message = "手机号码不能为空")
	private String phone;

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Override
	public String toString() {
		return "User [userId=" + userId + ", userName=" + userName + ", password=" + password + ", sex=" + sex + ", email=" + email + "]";
	}

}
